package com.liqi.display.controller;

import com.liqi.display.common.Results;
import com.liqi.display.common.SystemCode;
import com.liqi.display.service.ITblHandoutarchiveService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author liqi
 * @since 2021-06-24
 */
@RestController
@RequestMapping("/display/tbl-handoutarchive")
public class TblHandoutarchiveController {


    @Autowired
    private ITblHandoutarchiveService iTblHandoutarchiveService;

    /**
     * 获取最近10天数据
     * @return
     */
    @GetMapping("getLateTenNum")
    public Results getLateTenNum(){
        Results results=new Results();
        try {
            Map<String, Object> map = iTblHandoutarchiveService.lateTen();
            results.setData(map);
            results.setCode(SystemCode.SYS_OK.getKey());
            results.setMessage(SystemCode.SYS_OK.getValue());
            return results;
        }catch (Exception e){
            results.setData(null);
            results.setCode(SystemCode.SYS_FAIL.getKey());
            results.setMessage(SystemCode.SYS_FAIL.getValue());
            return results;
        }
    }


    /**
     * 获取当月数据
     * @return
     */
    @GetMapping("getCurMonth")
    public Results getCurMonth(){
        Results results=new Results();
        try {
            Map<String, Object> map = iTblHandoutarchiveService.totalMonth();
            results.setData(map);
            results.setCode(SystemCode.SYS_OK.getKey());
            results.setMessage(SystemCode.SYS_OK.getValue());
            return results;
        }catch (Exception e){
            results.setData(null);
            results.setCode(SystemCode.SYS_FAIL.getKey());
            results.setMessage(SystemCode.SYS_FAIL.getValue());
            return results;
        }
    }
}
